package spring.core.examples.xml;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Demonstrates the implementation of Spring callback using annotations. The
 * annotations allow extra actions during bean construction and destruction.<br>
 * <br>
 * Note: The annotations used in this example are not part of any Spring
 * artefakt!
 * 
 * @see LifecycleBean
 */
public class AnnotatedLifecycleBean {

	/**
	 * This method will be called before the containing Spring container will be
	 * destroyed.<br>
	 * <br>
	 * This method will only be called if a shutdown hook is registered to the
	 * Spring application context.
	 * 
	 * @see CoreContext
	 */
	@PreDestroy
	public void cleanup() {
		System.out.println("Cleanup bean " + this.getClass().getSimpleName());
	}

	/**
	 * This method is called after bean has been constructed and all the
	 * properties habe been set.
	 */
	@PostConstruct
	public void initialze() {
		System.out
				.println("Initialize bean " + this.getClass().getSimpleName());
	}

}
